<template>
  <!-- 查看r3日志 -->
  <div>
    <FilterTable
      ref="table"
      height="auto"
      maxHeight="350"
      columnsRef="partPartPurchasePurchaseOrderMainQueryR3Dialog"
      :dataSource="r3LogList"
      :isMemoryPagination="true"
      :isSelectColumn="false"
      :columns="tableColumns"
      :onColumnsChange="columns => (this.tableColumns = columns)"
    >
      <!-- <template slot="controls">
        <el-button size="small" type="primary">导出</el-button>
        <el-button size="small" type="primary">打印</el-button>
      </template>-->
    </FilterTable>
    <div class="bottomBtnWrap">
      <el-button @click="handleClose">关 闭</el-button>
      <!-- <el-button @click="handleConfirm" type="primary">确 定</el-button> -->
    </div>
  </div>
</template>

<script>
import { quertR3Log, queryAllOrderTypeInfo } from '@/api/part/partPurchase/purchaseOrder';

export default {
  props: {
    billNo: {
      type: String
    }
  },
  data() {
    return {
      tableColumns: this.createTableColumns(),
      orderTypeList: {}, // 所有订单类型(翻译用)
      r3LogList: [] // 日志列表
    };
  },
  mounted() {
    // this.$nextTick(() => {
    this.queryR3Log();
    // this.queryAllOrderTypeInfoList();
    // });
  },
  methods: {
    createTableColumns() {
      return [
        // {
        //   title: '单据类型',
        //   dataIndex: 'vCorType'
        // },
        {
          title: '订单类型',
          dataIndex: 'partTypeName',
          filter: true,
          filterType: 'input'
        },
        {
          title: '单据编号',
          dataIndex: 'orderNo',
          filter: true,
          filterType: 'input'
        },
        {
          title: '流水号',
          dataIndex: 'itemId',
          filter: true,
          filterType: 'input'
        },
        {
          title: '消息来源',
          dataIndex: 'a4',
          filter: true,
          filterType: 'input'
        },
        {
          title: '消息编码',
          dataIndex: 'msg',
          filter: true,
          filterType: 'input'
        },
        {
          title: '时间戳',
          width: 180,
          dataIndex: 'createdAt',
          dateFormat: 'yyyy-MM-dd hh:MM:ss',
          filter: true,
          filterType: 'input'
        },
        {
          title: '消息类型',
          dataIndex: 'a8',
          filter: true,
          filterType: 'input'
        },
        {
          title: '消息描述',
          width: 200,
          showOverflowTooltip: true,
          dataIndex: 'exp',
          filter: true,
          filterType: 'input'
        },
        {
          title: '备注',
          dataIndex: 'a10',
          filter: true,
          filterType: 'input'
        },
        {
          title: '相关单据号',
          dataIndex: 'vbeln',
          filter: true,
          filterType: 'input'
        },
        {
          title: '订单性质',
          dataIndex: 'a12',
          filter: true,
          filterType: 'input'
        }
      ];
    },
    // 查询所有订单类型
    async queryAllOrderTypeInfoList() {
      let res = await queryAllOrderTypeInfo();
      let obj = {};
      res.data.map(item => {
        obj[item.partTypeNo] = item.partTypeName;
      });
      this.orderTypeList = obj;
    },
    // 查询r3列表
    async queryR3Log() {
      this.$refs.table.START_LOADING();
      let res = await quertR3Log({
        billNo: this.billNo
      });
      this.$refs.table.STOP_LOADING();
      if (res.resultCode == 200) {
        this.r3LogList = res.data;
      }
    },
    handleClose() {
      this.$emit('close');
    }
  }
};
</script>

<style scoped>
.bottomBtnWrap {
  position: absolute;
  left: 0px;
  bottom: 0px;
  right: 0px;
  z-index: 9;
  border-top: 1px solid rgb(233, 233, 233);
  padding: 10px 20px;
  background: rgb(255, 255, 255);
  text-align: right;
}
</style>
